package org.congapps.employees.model;

import java.util.Date;

import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import static javax.persistence.TemporalType.DATE;

@Embeddable
public class TitleId implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	private int empNo;
	private String title;
	private Date fromDate;

	public TitleId() {
	}

	public TitleId(int empNo, String title, Date fromDate) {
		this.empNo = empNo;
		this.title = title;
		this.fromDate = fromDate;
	}

	public int getEmpNo() {
		return this.empNo;
	}

	public void setEmpNo(int empNo) {
		this.empNo = empNo;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Temporal(DATE)
	public Date getFromDate() {
		return this.fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof TitleId))
			return false;
		TitleId castOther = (TitleId) other;

		return (this.getEmpNo() == castOther.getEmpNo())
				&& ((this.getTitle() == castOther.getTitle()) || (this
						.getTitle() != null && castOther.getTitle() != null && this
						.getTitle().equals(castOther.getTitle())))
				&& ((this.getFromDate() == castOther.getFromDate()) || (this
						.getFromDate() != null
						&& castOther.getFromDate() != null && this
						.getFromDate().equals(castOther.getFromDate())));
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result + this.getEmpNo();
		result = 37 * result
				+ (getTitle() == null ? 0 : this.getTitle().hashCode());
		result = 37 * result
				+ (getFromDate() == null ? 0 : this.getFromDate().hashCode());
		return result;
	}

}
